//
//  FaceRegisterViewController.m
//  VisitorFacetestingSystem
//
//  Created by 张斌 on 16/7/7.
//  Copyright © 2016年 YueShiKeJi. All rights reserved.
//

#import "FaceRegisterViewController.h"
#import "AppDelegate.h"
#import "PhotoCollectionViewCell.h"
#import "UIColor+Random.h"
#import "takePhoto.h"
@interface FaceRegisterViewController ()
@property (weak, nonatomic) IBOutlet UICollectionView *MyConlectionView;
@property (weak, nonatomic) IBOutlet UICollectionViewFlowLayout *flowLayout;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *imgheight;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *colectionheight;
@property (weak, nonatomic) IBOutlet UIImageView *faceimg;

@end

@implementation FaceRegisterViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = @"人脸登记";
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"fanhuijian"] style:UIBarButtonItemStylePlain target:self action:@selector(back)];
}
- (IBAction)addfacebtn:(id)sender {
    [takePhoto sharePicture:^(UIImage *image) {
        self.faceimg.image = image;
    } :^(UIImagePickerController *pickerVc) {
        [self presentViewController:pickerVc animated:YES completion:nil];
    }];

}
- (void)back{
    [self.navigationController popViewControllerAnimated:YES];
}


-(void)viewDidLayoutSubviews{
    [super viewDidLayoutSubviews];
    //headlineVC依赖于newsconreoller
    [self setupFlowLayout];
}

-(void)setupFlowLayout{
    self.flowLayout.itemSize = CGSizeMake([UIScreen mainScreen].bounds.size.height * 80/667, [UIScreen mainScreen].bounds.size.height * 80/667);
    self.flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    self.flowLayout.minimumInteritemSpacing = 0;
    self.flowLayout.minimumLineSpacing = [UIScreen mainScreen].bounds.size.height * 20/667;
    
    self.MyConlectionView.pagingEnabled = YES;
    self.MyConlectionView.bounces = NO;
    self.MyConlectionView.showsHorizontalScrollIndicator = YES;
    
    self.imgheight.constant = [UIScreen mainScreen].bounds.size.height * 454/667;
    self.colectionheight.constant = [UIScreen mainScreen].bounds.size.height * 100/667;
    
}




// 代理
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    PhotoCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"PhotoCell" forIndexPath:indexPath];
    
    
    cell.tag = indexPath.item;

    cell.backgroundColor  = [UIColor Randomcolor];
    
    return cell;
}

-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
//    return self.headLineList.count;
    return 100;
}
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
    
    return 1;
}


@end
